package com.jch.helloworld.configBeans.annotation;

import com.jch.helloworld.configBeans.annotation.controller.DemoController;
import com.jch.helloworld.configBeans.annotation.repository.DemoRepositoryImpl;
import com.jch.helloworld.configBeans.annotation.service.DemoService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestMain {

    public static void main(String[] args) {

        ApplicationContext ctx = new ClassPathXmlApplicationContext("/beans/beans-annotation.xml");

        // 获取@Component 注解的类
        TestComponent testComponent = (TestComponent) ctx.getBean("testComponent");
        System.out.println(testComponent);

        // 获取@Controller 注解的类
        DemoController demoController = (DemoController) ctx.getBean("demoController");
        System.out.println(demoController);

        // 获取@Service 注解的类
        DemoService demoService = (DemoService) ctx.getBean("demoService");
        System.out.println(demoService);

        // 获取@Repository 注解的类
        DemoRepositoryImpl demoRepository = (DemoRepositoryImpl) ctx.getBean("demoRepository");
        System.out.println(demoRepository);

    }

}
